package com.binary.coder.gift.core.domain.sys;

import com.binary.coder.gift.core.common.bean.BizException;
import com.binary.coder.gift.core.common.bean.PageBean;
import com.binary.coder.gift.core.common.excel.ExcelExporter;
import com.binary.coder.gift.core.infrastructure.po.sys.SysApiSql;
import com.binary.coder.gift.core.interfaces.sys.dto.req.SysApiSqlAdd;
import com.binary.coder.gift.core.interfaces.sys.dto.req.SysApiSqlCellAliasUpdate;
import com.binary.coder.gift.core.interfaces.sys.dto.req.SysApiSqlQuery;
import com.binary.coder.gift.core.interfaces.sys.dto.req.SysApiSqlUpdate;

import java.util.List;
import java.util.Map;

/**
 * @author weitao
 */
public interface ISysApiSqlService {

    /**
     * @description: 按记录id查询数据
     * @author vincent
     * @date 2024/2/23 16:14
     * @version 1.0
     */
    Object queryDataById(long id, Map<String, Object> param) throws BizException;

    /**
     * @description: 按编码查询数据
     * @author vincent
     * @date 2024/2/23 16:32
     * @version 1.0
     */
    Object queryDataByCode(String code, Map<String, Object> param) throws BizException;

    /**
     * @description: 验证sql语句的合法性
     * @author vincent
     * @date 2024/2/23 16:33
     * @version 1.0
     */
    String validSql(SysApiSql api, Map<String, Object> param);

    /**
     * @description: 根据编码查询sql配置
     * @author vincent
     * @date 2024/2/23 16:34
     * @version 1.0
     */
    SysApiSql getByCode(String code);

    /**
     * @description: 导出excel
     * @author vincent
     * @date 2024/2/23 16:38
     * @version 1.0
     */
    void exportExcelBySql(ExcelExporter excelExporter, Long apiId, String sql, int script, Map<String, Object> param);

    /**
     * @description: 导出excel
     * @author vincent
     * @date 2024/2/23 16:38
     * @version 1.0
     */
    void exportExcelBySql(ExcelExporter excelExporter, String selectSql, Map<String, Object> param);

    /**
     * @description: 分页查询
     * @author vincent
     * @date 2024/2/23 16:46
     * @version 1.0
     */
    PageBean<SysApiSql> queryByPage(SysApiSqlQuery param);

    /**
     * @description: ID获取数据
     * @author vincent
     * @date 2024/2/23 16:48
     * @version 1.0
     */
    SysApiSql getById(Long id);

    /**
     * @description: 新增sql配置
     * @author vincent
     * @date 2024/2/23 16:49
     * @version 1.0
     */
    SysApiSql addBean(SysApiSqlAdd param, int script) throws BizException;

    /**
     * @description: 更新sql配置
     * @param: param
     * @param: script
     * @return: com.cisdi.colmet.core.admin.mybatis.sys.entity.SysApiSql
     * @author vincent
     * @date: 2024/2/27 14:01
     */
    SysApiSql updateBean(SysApiSqlUpdate param, int script) throws BizException;

    /**
     * @description: 设置列别名
     * @param: param
     * @return: void
     * @author vincent
     * @date: 2024/2/27 14:01
     */
    void saveCellAlias(SysApiSqlCellAliasUpdate param);

    /**
     * @description: 根据sql语句查询数据
     * @param: apiId
     * @param: sql
     * @param: script
     * @param: page
     * @param: param
     * @return: java.util.List<java.util.Map < java.lang.String, java.lang.Object>>
     * @author vincent
     * @date: 2024/2/27 14:02
     */
    List<Map<String, Object>> queryBySql(Long apiId, String sql, int script, int page, Map<String, Object> param);

    /**
     * @description: 查询表和表的所有字段
     * @return:
     * @return: java.util.Map<java.lang.String, java.util.List < java.util.Map < java.lang.String, java.lang.String>>>
     * @author vincent
     * @date: 2024/2/27 14:05
     */
    Map<String, List<Map<String, String>>> getTableAndColumns();
}
